using UnityEngine;
using System.Collections.Generic;

public static class CoverCache
{
    private static Dictionary<string, Sprite> spriteCache = new();

    public static Sprite GetCover(string fileName)
    {
        if (!spriteCache.ContainsKey(fileName))
        {
            string path = "Pictures/Covers/" + fileName;
            Sprite sprite = Resources.Load<Sprite>(path);
            if (sprite != null)
            {
                spriteCache[fileName] = sprite;
            }
            else
            {
                Debug.LogError("Failed to load cover: " + path);
                return null;
            }
        }

        return spriteCache[fileName];
    }
}
